<%--
  Created by IntelliJ IDEA.
  User: 王文尧
  Date: 2024/7/10
  Time: 16:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        request.setAttribute("tName", "zhw老师");
    %>
    <%-- 指定 范围对象 设置属性 --%>
    <c:set var="tName" value="zhw老师" scope="request"></c:set>
    <%-- 如果没有指定范围，则为最小的 page 的 --%>
    <c:set var="tNo" value="101"></c:set>

    ${tName}
    <hr/>
    pageScope:${pageScope.tNo}<br/>
    requestScope:${requestScope.tNo}<br/>
    sessionScope:${sessionScope.tNo}<br/>
    applicationScope:${applicationScope.tNo}<br/>

    <%-- 测试 移除属性 --%>

    <c:set var="sex" value="男1" scope="page"></c:set>
    <c:set var="sex" value="男2" scope="request"></c:set>
    <c:set var="sex" value="男3" scope="session"></c:set>
    <c:set var="sex" value="男4" scope="application"></c:set>

    <hr/>
    添加 sex 属性：<br/>
    pageScope:${pageScope.sex}<br/>
    requestScope:${requestScope.sex}<br/>
    sessionScope:${sessionScope.sex}<br/>
    applicationScope:${applicationScope.sex}<br/>
    <%-- 如果有设置范围，则移除 范围对象的属性 --%>
    <%--<c:remove var="sex" scope="page" ></c:remove>--%>
    <%-- 如果没有设置范围，则移除全部范围对象的属性 --%>
    <c:remove var="sex"></c:remove>

    <hr/>
    移除sex属性:<br/>
    pageScope:${pageScope.sex}<br/>
    requestScope:${requestScope.sex}<br/>
    sessionScope:${sessionScope.sex}<br/>
    applicationScope:${applicationScope.sex}<br/>
</body>
</html>
